<template>
  <div class="testpage">
    <h2>{{ msg }}</h2>

    <div class="time"></div>
    <div class="wrapper">
      <div>
        <p class="verticalBar"></p>
      </div>

      <div style="margin-left: 10px;">
        <button class="button button1" @click="go1">实时地图</button>
        <br>
        <button class="button button1" @click="go1">AIT信息</button>
        <br>
        <button class="button button1" @click="addTask">添加任务</button>
      </div>
    </div>
  </div>
</template>


<script>

  export default {
    name: 'testpage',
    data () {
      return {
        msg: '跳转测试',
        task: {
          start_pos: 0,
          end_pos: 0,
          containers: 0,
          start_time: 0,
          end_time: 0
        }
      }
    },
    methods:{
      go1(){
        this.$router.push('/map')
      },
      // go2(){
      //   this.$router.push('/map')
      // },
      addTask(){
        //发送任务
        var i = 0, tasks = 3
        for(i; i<tasks; i++)
        {
          switch(i){
            case 0: {
              this.task.start_pos = 1
              this.task.end_pos = 0
              this.task.containers = 2
              this.task.start_time = 1
              this.task.end_time = 9
              break
            }
            case 1: {
              this.task.start_pos = 10
              this.task.end_pos = 3
              this.task.containers = 2
              this.task.start_time = 2
              this.task.end_time = 6
              break
            }
            case 2: {
              this.task.start_pos = 24
              this.task.end_pos = 5
              this.task.containers = 4
              this.task.start_time = 2
              this.task.end_time = 10
              break
            }
            default: break
          }
          console.log("添加了任务#", i)
          this.$axios.post('http://127.0.0.1:8087/task/add', this.task)
            .then(function (response) {
              console.log(response.data)
            })
            .catch(function (error) {
              console.log(error);
            });
        }

        //this.$router.push('/map')
      }
    }
  }

</script>

<style>
  .button {
    background-color: #00bfff;
    border: 1px solid #c3c3c3;
    color: white;
    padding: 15px 32px;
    text-align: center;
    font-size: 16px;
    display: inline-block;
    margin: 40px 0;
    cursor: pointer;
  }

  .verticalBar {
    width: 4px;
    height: 600px;
    background: #c3c3c3;
    display: inline-block;
    margin-right: 0;
  }

  .wrapper {
    display: inline-flex;
    justify-content: space-around;
    align-items: center;
  }

  .button1 {width: 500px;}

</style>
